#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stack>

using namespace std;

string decodeString(string s) {
    stack<string> st;
    st.push("");

    stack<int> nums;

    int i = 0;
    int n = s.size();

    while (i < n)
    {
        if (s[i] >= '0' && s[i] <= '9')
        {
            int tmp = 0;
            while (s[i] >= '0' && s[i] <= '9')
                tmp = tmp * 10 + (s[i++] - '0');
            nums.push(tmp);
        }
        else if (s[i] == '[')
        {
            ++i;
            string tmp;
            while (s[i] >= 'a' && s[i] <= 'z')
                tmp += s[i++];
            st.push(tmp);
        }
        else if (s[i] == ']')
        {
            ++i;
            string tmp = st.top();
            st.pop();

            int k = nums.top();
            nums.pop();

            while (k--)
            {
                st.top() += tmp;
            }
        }
        else
        {
            while (i < n && s[i] >= 'a' && s[i] <= 'z')
                st.top() += s[i++];
        }
    }

    return st.top();
}

int main()
{

	return 0;
}